<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>站点配置</title>
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js" charset="utf-8"></script>
  <style>
    *{
    margin: 0;
    padding: 0;
  }
  .box{
    position:relative;
    width: 100vw;
    height:100vh;
    background-color: #000;
  }
  .point{
    position:absolute;
  }
  .menu{
    position: absolute;
    list-style: none;
    display:none;
  }
  .add-btn{
    padding:3px 5px;
    background-color: red;
    color:#fff;
  }
  .popupRight{
    position: fixed;
    width:15vw;
    height:100vh;
    top:0;
    right:-15vw;
    background: #fff;
    transition: all .5s;
  }
  .popupRight h3{
    margin: 15px;
  }
  .attrs{
    font-size: 12px;
border: 1px solid #889;
height: 35px;
line-height: 35px;
margin: 10px 11px 0 11px;
border-radius: 5px;
  }

  .attrs span{
    margin-left: 6px;
  }
  .attrs input{
    width: 29%;
    border-radius: 3px;
    outline: none;
    border: 1px solid #ccc;
    margin-left: 2%;
    text-align: center;
    height: 22px;
  }
.attr-wrap{
  position: relative;
}
  .addAttr{
    width: 25px;
position: absolute;
bottom: -19px;
left: 45%;
  }
  .fotter{
    text-align: center;
    bottom: 30px;
    position: absolute;
    width: 100%;
  }
  .fotter button{
    padding: 8px 13px;
background: blue;
color: #fff;
border-radius: 8px;
outline: none;
border: 1px solid red;
  }
  </style>
</head>

<body>
  <div class="box">
    <div id="content">

    </div>
    <ul class='menu'>
      <li><button type="button" class='add-btn'>添加站点</button> </li>
    </ul>
  </div>
  <div class="popupRight">
    <h3>属性</h3>

    <div class='attr-wrap'>
        <button type="button" name="button" class='addAttr'>+</button>
    </div>
    <div class="fotter">
      <button type="button" name="button" class='attr-confirm'>确定</button>
    </div>
  </div>
</body>
<script>
var attrBox =   document.querySelector('.attr-wrap')
var elLeft,elTop,attrObj={};
  document.oncontextmenu = function(ev) {
    var clintX = ev.clientX; //ev获取的只是屏幕可视范围的x,y值
    var clintY = ev.clientY;
    var scollTop = document.documentElement.scrollTop || document.body.scrollTop; //当有下拉条的时候必须加上当前屏幕不可视范围的left,和top值
    var scollLeft = document.documentElement.scrollLeft || document.body.scrollLeft
  elLeft = document.getElementsByTagName('ul')[0].style.left = clintX + scollLeft + 'px';
  elTop = document.getElementsByTagName('ul')[0].style.top = clintY + scollTop + 'px';
    document.getElementsByTagName('ul')[0].style.display = 'block';
    return false; //阻止鼠标右键菜单出现
  }
  $("button[class=addAttr]:last").on('click',function(){ // 新增属性
    var $div=$('<div>').html('<span>属性名</span><input type="text" name="" value=""><span>属性值</span><input type="text" name="" value="">').attr('class','attrs')
    $(attrBox).append($div)
  })
  $('.add-btn').on('click',function(){ // 右键确定
    $('.popupRight').css('right','0')
    $('.menu').css('display','none')
  })
  $('.attr-confirm').on('click',function(){ // 属性确定
    $('.popupRight').css('right','-15vw')
    $('#content').append(`<input type="radio" class="point" style=left:${elLeft};top:${elTop}>`)
  })
</script>

</html>
